package Function.ItemUse;

import FCRendering.FCRMaster;
import VWorldGameStudio.FCBattleOrder;
import VWorldGameStudio.FCMonster;
import VWorldGameStudio.FCPlayerInfo;
import VWorldGameStudio.FCTank;

import static FCRendering.FCRMaster.fcv;

public class PlateTypeItemUse extends AItemUse{
    @Override
    public ItemUseResult directUse() {
        return  useForTankTarget(keepItemTank);
    }

    @Override
    public ItemUseResult useInMapTarget(int x, int y) {
        return  useForTankTarget(keepItemTank);
    }

    @Override
    public ItemUseResult useForMonsterTarget(FCBattleOrder battleOrder, FCMonster m) {
        return useForTankTarget(keepItemTank);
    }

    @Override
    public ItemUseResult useForPlayerTarget(FCPlayerInfo p) {
        return  useForTankTarget(keepItemTank);
    }

    @Override
    public ItemUseResult useForTankTarget(FCTank t) {
        if(t == null){
            return new ItemUseResult().useless();
        }
        fcv.closeAllShowWindw();
        ItemUseResult result = new ItemUseResult();
        if(useItem.getDefenseAdd() > 0 && t.getDefense() != t.getMaxDefense()){
            int n = t.getDefense()+useItem.getDefenseAdd();
            n = Math.min(t.getMaxDefense(), n);
            t.setDefense(n);
            t.reInitShuxing();
            result.resultString.add("给"+ FCRMaster.langLib.getNameOfId(t.getName())+"恢复SP"+n+"点");
            fcv.getMessage().add("给"+ FCRMaster.langLib.getNameOfId(t.getName())+"恢复SP"+n+"点");
            fcv.showMessage();
            useAfter();
        }else {
            result.resultString.add("坦克的装甲已经是满的哦！");
            fcv.getMessage().add("坦克的装甲已经是满的哦！");
            fcv.showMessage();
        }
        return result;
    }
}
